let map = function(arr,fun){
    let result = []
    for(let value of arr){
        result.push(fun(value))
    }
    return result;
}

let arr = [1,2,3,4,5,6,7,8]

console.log(map(arr,(item)=>{return item*item}));